#!/usr/bin/env python
# coding: utf8

from PySide.QtGui import *

class MyWidget(QWidget):
    firstStepList = [". build/envsetup.sh"]
    secondTargetList = ["full-eng"]
    thirdTargetList = ["release", "debug"]
    def __init__(self, listForMakeTarget):
        QWidget.__init__(self)
        if not isinstance(listForMakeTarget, list):
            QMessageBox.critical(self, unicode("参数错误", "utf8"), unicode("请输入正确的参数！", "utf8"))
            exit(1)
        
        self.targetList = listForMakeTarget
        self.initViews()
        self.initConnects()

    def initViews(self):
        self.firstStep = QComboBox()
        self.firstStep.addItems(self.firstStepList)

        self.secondStep = QHBoxLayout()
        self.secStepLabel = QLabel("lunch")
        self.secStepTarget = QComboBox()
        self.secStepTarget.addItems(self.secondTargetList)
        self.secondStep.addWidget(self.secStepLabel)
        self.secondStep.addWidget(self.secStepTarget)

        self.thirdStep = QHBoxLayout()
        self.thdStepLabel = QLabel("chooseType")
        self.thdStepTarget = QComboBox()
        self.thdStepTarget.addItems(self.thirdTargetList)
        self.thirdStep.addWidget(self.thdStepLabel)
        self.thirdStep.addWidget(self.thdStepTarget)

        self.firthStep = QHBoxLayout()
        self.firthLabel = QLabel("make")
        self.firthTarget = QComboBox()
        self.firthTarget.addItems(self.targetList)
        self.firthButton = QPushButton(unicode("只运行这一步", "utf8"))
        self.firthStep.addWidget(self.firthLabel)
        self.firthStep.addWidget(self.firthTarget)
        self.firthStep.addWidget(self.firthButton)

        self.buttons = QHBoxLayout()
        self.btnRunAll = QPushButton(unicode("按顺序执行全部", "utf8"))
        self.btnExit = QPushButton(unicode("退出", "utf8"))
        self.buttons.addWidget(self.btnRunAll)
        self.buttons.addWidget(self.btnExit)

        self.mainLyt = QVBoxLayout(self)
        self.mainLyt.addWidget(self.firstStep)
        self.mainLyt.addLayout(self.secondStep)
        self.mainLyt.addLayout(self.thirdStep)
        self.mainLyt.addLayout(self.firthStep)
        self.mainLyt.addLayout(self.buttons)

    def initConnects(self):
        self.btnRunAll.clicked.connect(self.onRunAllButtonClicked)
        self.firthButton.clicked.connect(self.onFirthButtonClicked)
        self.btnExit.clicked.connect(self.onExitClicked)

    def onRunAllButtonClicked(self):
        print("run all")

    def onFirthButtonClicked(self):
        print("只运行这一步")

    def onExitClicked(self):
        exit(0)
        
if __name__ == '__main__':
    import sys
    myApp = QApplication(sys.argv)
    w = MyWidget([])
    w.show()
    exit(myApp.exec_())
